#ifndef HSE_DOCUMENT_READER_H
#define HSE_DOCUMENT_READER_H
#include <string>
#include <vector>
#include <stdio.h>
#include "hse_common.h"
#include "hse_types.h"

namespace hse {

using std::string;
using std::vector;


class DocumentReader {
public:
	static const int kBufferSize = 4096 * 4096 * 8;
	
	explicit DocumentReader(const char* doc_name);
	~DocumentReader();

	int Init();
	inline vector<DocWord*>& GetWords() {return words_;}
	inline int GetId() { return id_; }
	inline int GetLength() {return length_; }
	inline static void Open() {
		buffer = new char[kBufferSize];
	}
	inline static void Close() {
		delete[] buffer;
		buffer = NULL;
	}

private:
	static int ID_ ;
	static char *buffer;

	FILE *doc_;
	string doc_name_;
	int id_;
	vector<DocWord*> words_;
	int length_;

	int OpenFile();
	void ParseWords();

	DISALLOW_COPY_AND_ASSIGN(DocumentReader);
};



}

#endif